<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>demo sc - 账户登录</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <link rel="stylesheet" href="css/default.css">
    <script type="text/javascript">
        $(document).ready(function () {
            $("#login").bind("click", () => {
                if ($("#email").val() == "") {
                    $("#warning").text("请填写邮箱！");
                    return;
                }
                if ($("#password").val() == "") {
                    $("#warning").text("请填写密码！");
                    return;
                }

                $("#warning").text("");
                var url = "/api/user/login/" +
                    $("#email").val() + "/" +
                    $("#password").val();
                $.ajax({
                    url: url,
                    success: function (result) {
                        if (result == "") {
                            $("#warning").text("登录失败，邮箱或密码错误！");
                        } else {
                            location.href = "welcome.html";
                        }
                    }
                });
            });
        });
    </script>
</head>

<body>
    <div class="container flex">
        <div class="login boxer flex">
            <header>用户登录</header>
            <div class="boxer-form">
                <div class="inputbox flexr">
                    <span>邮箱</span>
                    <input type="text" id="email" maxlength="40">
                </div>
                <div class="inputbox flexr">
                    <span>密码</span>
                    <input type="password" id="password" maxlength="20">
                </div>
                <div class="warning" id="warning"></div>
            </div>
            <div class="login_button flex">
                <button id="login">登录</button>
            </div>
            <a href="register.html" title="注册新账号" class="reg_link">注册新账号</a>
        </div>
    </div>
</body>

</html>